package edu.cibertec.alquiler.dao.persistence;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

import util.MySqlDBConn;

import edu.cibertec.alquiler.bean.GeneroBean;


public class CategoriaDAOImpl {
	
	
	public ArrayList<GeneroBean> getGeneros() throws Exception{
		
ArrayList<GeneroBean> generos = new ArrayList<GeneroBean>();
		
		String sql = "SELECT * FROM tb_genero";
		System.out.println("SENTENCIA SQL : " + sql);
		
		Connection conn = new MySqlDBConn().getConnection();
		Statement stm = conn.createStatement();
		System.out.println("query : "+sql);
		ResultSet rst = stm.executeQuery(sql);
		while (rst.next()){
			GeneroBean b = new GeneroBean();
			b.setCod(rst.getString(1));
			b.setDescripcion(rst.getString(2));
			generos.add(b);
		}
		rst.close();
		stm.close();
		conn.close();

		return generos;
	
	}

}
